package com.baidu.travel.timedtask.timer;


import com.baidu.travel.timedtask.service.CommentTimingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;

@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling
public class TimingCache {
    @Autowired
    private CommentTimingService commentTimingService;

    @Scheduled(fixedRate=60*5*1000)
    private void configureTasks() {
        Boolean aBoolean = commentTimingService.timedCacheComments();
        System.err.println("执行定时将评论缓存到redis"+ LocalDateTime.now());
    }
}
